﻿using InvestmentIntelligence.DbModel.Models;
using System;
using System.Collections.Generic;

namespace InvestmentIntelligence.Data.Repository.Comparers.EntityModelsComparers
{
    public sealed class TradeComparer : IEqualityComparer<Trade>
    {
        public bool Equals(Trade x, Trade y)
        {
            if (ReferenceEquals(x, y)) return true;
            if (ReferenceEquals(x, null)) return false;
            if (ReferenceEquals(y, null)) return false;
            if (x.GetType() != y.GetType()) return false;
            return x.Id == y.Id &&
                String.Equals(x.OriginalId, y.OriginalId) && 
                x.FundBookEntityId == y.FundBookEntityId &&
                x.SecurityId == y.SecurityId &&
                x.CurrencyId == y.CurrencyId &&
                x.StrategyId == y.StrategyId &&
                x.Date.Equals(y.Date) &&
                x.FxRate == y.FxRate &&
                x.Quantity == y.Quantity &&
                x.Price == y.Price &&
                x.Size == y.Size;
            //TraderId ???
        }

        public int GetHashCode(Trade obj)
        {
            return 1;
        }
    }
}
